package assignments

import scala.collection.mutable._

/**
 * Class that contains tasks for an assignments and their results.
 * @author Jacob Biggs
 *
 */
case class Assignment(id : Int, level : Int, tasks : ListBuffer[ ProjectTask ]) {
  var results : ListBuffer[ProjectResult] = new ListBuffer[ProjectResult]
  
  /**
   * Calculate the total progress of the assignment based on number of complete tasks
   * @return Percent
   */
  def progress : Double = (tasks.count(task => task.complete == true).toDouble / tasks.length.toDouble)*100d
  
  /**
   * Prepares data for delivery to server with final computations
   */
  def pack()
  {
    throw new Exception("pack() method not implemented")
  }
  
  /**
   * Produces and returns final AssignmentResult object to be sent to server
   */
  def collect() : AssignmentResult =
  {
    throw new Exception("collect method not implemented")
  }
}

/**
 * Class use to contain data to be sent back to server
 * @author Jacob Biggs
 *
 */
case class AssignmentResult(id: Int, value: Option[Any] )

/**
 * Class for an unassigned assignment.
 * @author Jacob Biggs
 *
 */
case object NoAssignment extends Assignment(0, 0, new ListBuffer[ ProjectTask])